<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

	<ui:composition 
	  xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      template="/view/templates/templateLayout.xhtml">
      
      <ui:define name="conteudo">    
      <link rel="stylesheet" type="text/css" href="./estilos.css"/>   	
  	
<h:form id="formExcluirFormaPagamento" prependId="false">  
	<p:panel id="panelExcluirCondicaoPagamento" header="Excluir FormaPagamento" style="margin-bottom:20px; ">  
	<f:facet name="header">
		<h:outputText value="Excluir Condição de Pagamento" styleClass="outputTextTitulo"/>
	</f:facet> 
 	<p:messages id="messages" autoUpdate="true" closable="true" showDetail="true"/> 
    	<h:panelGrid id="pgCondicaoPagamento" columns="2" style="margin-top:20px; margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Condição de Pagamento*" styleClass="outputLabel"/>             
            <p:inputText value="#{condicaoPagamentoBean.condicaoPagamentoSave.idCondicaoPagamento}" styleClass="inputId" disabled="true" />  
  			<p:inputText value="#{condicaoPagamentoBean.condicaoPagamentoSave.descricao}" styleClass="inputDescricao" required="true" requiredMessage="Informe o nome da Condição de Pagamento!"/>  
        </h:panelGrid>  
        <h:panelGrid id="pgFormaPgto" columns="3" style="margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Forma de Pagamento*" styleClass="outputLabel"/>      
            <h:outputLabel  />       
            <p:inputText value="#{condicaoPagamentoBean.condicaoPagamentoSave.formaPagamento.idFormaPagamento}" styleClass="inputId" disabled="true" />  
  			<p:inputText value="#{condicaoPagamentoBean.condicaoPagamentoSave.formaPagamento.descricao}" styleClass="inputDescricao" required="true" requiredMessage="Informe o nome da Condição de Pagamento!"/>  
  			<p:commandButton icon="ui-icon-search" action="#{condicaoPagamentoBean.openDialogConsultarFormaPagamento}" immediate="true"/>
        </h:panelGrid>  
        <h:panelGrid id="pgJuros" columns="2" style="margin-right:10%;">  
            <h:outputLabel value="Juros(%)" styleClass="outputLabel"/>  
            <h:outputLabel value="Desconto(%)" styleClass="outputLabel"/>      
            <p:inputMask  id="juros" value="#{condicaoPagamentoBean.condicaoPagamentoSave.juros}" maxlength="6" styleClass="inputId" />      
  			<p:inputMask value="#{condicaoPagamentoBean.condicaoPagamentoSave.desconto}" styleClass="inputId"/>  
        </h:panelGrid> 
        <h:panelGrid id="pgParcela" columns="5" style="margin-right:10%;">  
            <h:outputLabel value="Parcela" styleClass="outputLabel"/>  
            <h:outputLabel value="Prazo(dias)*" styleClass="outputLabel"/>   
            <h:outputLabel value="Percentual*" styleClass="outputLabel"/>   
            <h:outputLabel  />
            <h:outputLabel  />
            <p:inputMask  value="#{condicaoPagamentoBean.parcela.numero}" styleClass="inputId" disabled="true" />  
  			<p:inputMask value="#{condicaoPagamentoBean.parcela.dias}" styleClass="inputId" required="true" requiredMessage="Informar o número de dias!"/>  
  			<p:inputMask  value="#{condicaoPagamentoBean.parcela.percentual}" styleClass="inputId" required="true" requiredMessage="Informar o percentual!"/>  
  			<p:commandButton icon="ui-icon-circle-plus" action="#{condicaoPagamentoBean.addParcela}" update="pgCondicaoPagamento, pgFormaPgto, pgJuros, pgParcela, messages"/>
  			<p:commandButton value="Limpar" action="#{condicaoPagamentoBean.clean}" update="tableParcela" immediate="true"/>
        </h:panelGrid> 
        
        <p:dataTable  id="tableParcela" value="#{condicaoPagamentoBean.listaParcela}" var="parcela" style="margin-top:30px; width:40%"  
        				rowKey="#{parcela.idParcela}" selection="#{condicaoPagamentoBean.parcelaSelect}" >
			<p:column>
				<f:facet name="header">
					<h:outputText value="Parcela" />
				</f:facet>
				<h:outputText value="#{parcela.numero}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="Prazo" />
				</f:facet>
				<h:outputText value="#{parcela.dias}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="Percentual" />
				</f:facet>
				<h:outputText value="#{parcela.percentual}" />
			</p:column>

       	 	<p:column style="width:4%">  
        		<f:facet name="header">
        	 		<h:outputText value="Excluir" />
        		</f:facet>
         		<p:commandButton icon="ui-icon-pencil" title="Remover" actionListener="#{condicaoPagamentoBean.removeParcela}" immediate="true">
         			<f:setPropertyActionListener target="#{condicaoPagamentoBean.parcelaSelect}" value="#{parcela}" />
         		</p:commandButton>
       	 	</p:column > 	
       	 	<f:facet name="footer" >
       	 		<h:outputText value="Total = #{condicaoPagamentoBean.totalParcela}%" >
       	 			
       	 		</h:outputText>
       	 	</f:facet>        
        </p:dataTable>
    </p:panel>  
    <p:commandButton value="Salvar" action="#{condicaoPagamentoBean.saveCondicaoPagamento}" update="panelExcluirCondicaoPagamento" styleClass="commandButton" /> 
	<p:commandButton value="Cancelar" action="#{condicaoPagamentoBean.consultarCondicaoPagamento}" immediate="true" styleClass="commandButton" /> 
</h:form>  	
<ui:include src="/view/condicaoPagamento/dialogConsultarFormaPagamento.xhtml"></ui:include>

</ui:define>
</ui:composition>
